home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-11-19 | 2.3 KB | 103 lines | [TEXT/MPS ] |
- /*
- File: TestFSet.cp
-
- Contains: Implementation of class TTestFSet
-
- Copyright: © 1992-1994 by Apple Computer, Inc., all rights reserved.
-
- */
-
- #ifndef __TESTFSET__
- #include "TestFSet.h"
- #endif
- #ifndef __FSETTEST__
- #include "FSetTest.h"
- #endif
-
- TTestFSet::TTestFSet()
- {}
-
- TTestFSet::~TTestFSet()
- {}
-
- void TTestFSet::InitTest(BooleanParm, BooleanParm, int, char**)
- {}
-
- void TTestFSet::EndTest(BooleanParm, BooleanParm)
- {}
-
- void TTestFSet::RunTestIteration(BooleanParm verbose, BooleanParm)
- {
- OSErr err;
- TClassInfo* info;
- info = GetLocalLibraryManager()->GetClassInfo(ClassID(kFSetParentID), &err);
- if (info == NULL)
- {
- Printf("### ERROR: #%d getting the TClassInfo object\n", err);
- return;
- }
- char* id;
- short count = 0;
- short mask = 0;
- while ((id = (char*)info->Next()) != NULL)
- {
- if (ClassID(id) == ClassID(kFSetTest1ID))
- {
- if (mask & 1)
- Printf("### ERROR: Get ID for function set #1 again\n");
- else
- {
- count += 1;
- mask |= 1;
- if (verbose)
- Printf("### INFO: Got ID for function set #1, version = %04X...%04X\n",
- info->GetMinVersion(), info->GetVersion());
- }
- }
- else
- if (ClassID(id) == ClassID(kFSetTest2ID))
- {
- if (mask & 2)
- Printf("### ERROR: Get ID for function set #2 again\n");
- else
- {
- count += 1;
- mask |= 2;
- if (verbose)
- Printf("### INFO: Got ID for function set #2, version = %04X...%04X\n",
- info->GetMinVersion(), info->GetVersion());
- }
- }
- else
- {
- Printf("### ERROR: Get \"%s\" as one of the subclass IDs\n", id);
- }
- }
- if (count != 2)
- Printf("### ERROR: Got %u \"classes\" as subclasses of \"%s\"\n",
- count, kFSetParentID);
- else
- {
- TestFunction test1;
- TestFunction test2;
- test1 = (TestFunction)GetFunctionPointer(ClassID(kFSetTest1ID), kFunctionName, &err);
- if (test1 == NULL)
- Printf("### ERROR: #%d Getting function pointer for function set #1\n",
- err);
- test2 = (TestFunction)GetFunctionPointer(ClassID(kFSetTest2ID), kFunctionName, &err);
- if (test2 == NULL)
- Printf("### ERROR: #%d Getting function pointer for function set #2\n",
- err);
- if (test1 != NULL && test2 != NULL)
- {
- int a = (*test1)(5,2);
- int b = (*test2)(5, 2);
- if (a != 7)
- Printf("### ERROR: function set #1 returned %d instead of 7\n", a);
- if (b != 3)
- Printf("### ERROR: function set #2 returned %d instead of 3\n", b);
- }
- }
- delete info;
- }
-